package com.xyb.controller;

import com.xyb.entity.Course;
import com.xyb.entity.CourseTopic;
import com.xyb.service.WebCourseService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("web")
public class WebCourseController {
    @Resource
    private WebCourseService webCourseService;

    @GetMapping("/base")
    public List<Course> selectBaseCourseList(){
        List<Course> list = webCourseService.selectBaseCourseList();
        return list;
    }

    @GetMapping("/hot")
    public List<Course> selectHotCourseList(){
        List<Course> list = webCourseService.selectHotCourseList();
        return list;
    }

    @GetMapping("/{courseId}")
    public Course selectCourseInfoByCourseId(@PathVariable("courseId") Long courseId){
        Course course = webCourseService.selectCourseByCourseId(courseId);
        return course;
    }

    @GetMapping("/recent/{userId}")
    public List<Course> selectRecentCourseListByUserId(@PathVariable("userId") Long userId){
        List<Course> list = webCourseService.selectRecentCourseListByUserId(userId );
        return list;
    }

    @GetMapping("/topic-course-list")
    public List<CourseTopic> selectTopicCourseAndCourseList(){
        List<CourseTopic> list = webCourseService.selectTopicCourseAndCourseList();
        return list;
    }
}
